Vue.component("login", {
  data() {
    return {
      u: "",
      p: "",
      dv: false
    }
  },
  props: ["showdv"],
  template: `<el-dialog title="登录" :visible.sync="dv" width="20%" center>
    <div style="text-align:center;">
      <el-input v-model="u" placeholder="用户名"></el-input><br/><br/>
      <el-input v-model="p" type="password" placeholder="密码"></el-input>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="opendata">登 录</el-button>
      <el-button @click="dv = false">取 消</el-button>
    </span>
  </el-dialog>`,
  methods: {
    opendata: function () { //请求数据
      var $this = this;
      axios.get("/s/login?U=" + this.u + "&P=" + this.p).then(function (res) {
        if (res.data.code == 0) {
          $this.dv = false;
          $this.$emit('loadmenu');
        };
      });
    },
    show:function(){
      this.dv = true;
    }
  },
  created:function(){
    //console.log("created");
    this.dv = this.showdv;
  }
});